# -*- coding:utf-8 -*-
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer

from UserService import UserService
from UserService import ttypes

class TestServiceHandler:
    def getUser(self):
        userDto = ttypes.UserDto(1,"tieshen")
        return userDto


handler = TestServiceHandler()

processor = UserService.Processor(handler)
transport = TSocket.TServerSocket(host='127.0.0.1',port=9090)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()

server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)

print("python server:ready to start")
server.serve()
print("done!")
